Set Home Directory
# setwd("/home/yourname/NYCTaxiData")
Load data
mydata = read.csv("sample.csv")
Install t-map package (Library for thematic maps) and other required R packages
#install.packages("dplyr")
#install.packages("sf")
#install.packages("curl")
#Restart your R Session
#install.packages("tmap")
Install ggmap
#install.packages("ggmap")
#OR (choose whichever works on your computer)
#install.packages("devtools")
#devtools::install_github("dkahle/ggmap")
Load libraries
library(dplyr)
library(sf)
library(curl)
library(ggmap)
library(tmap)
library(tmaptools)
Download and view map
map<-get_stamenmap(rbind(as.numeric(paste(geocode_OSM("Manhattan")$bbox))), zoom = 11)
ggmap(map)
Plot pickup locations
ggmap(map) + geom_point(aes(x = pickup_longitude, y = pickup_latitude),colour="white", size = 0.01, data = mydata, alpha = .5)
Square binning
plotmap <- ggmap(map) + geom_bin2d(bins=100, data=mydata, aes(x =
pickup_longitude, y = pickup_latitude))
plotmap
Install HexBin
#install.packages("hexbin")
Plot HexBIn
plotmapHB <- ggmap(map) + coord_cartesian() + geom_hex(bins=100, data=mydata,
aes(x = pickup_longitude, y = pickup_latitude))
plotmapHB